Skip to content

feat(code): suggested task cleanup#2273

Open
adboio wants to merge 2 commits into
mainfrom
05-20-feat_code_run_enricher_per_repo
Open

feat(code): suggested task cleanup#2273
adboio wants to merge 2 commits into
mainfrom
05-20-feat_code_run_enricher_per_repo

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented May 21, 2026

Problem

  1. the enricher run only runs one, during onboarding. it should run per-repo
  2. suggested tasks are not scoped to a particular repo
  3. signals team has cool plans for the inbox, so we need to remove the suggested tasks from there

Changes

  • suggestions-update.mp4 (uploaded via Graphite)

    makes all task suggestions (enricher + discovery) scoped to a repo

  • runs enricher on any new repo selected

  • removes suggestions from inbox

  • clicking a suggestion now opens a modal w/ task details and options to implement or dismiss

  • "see N more in inbox" is gone, suggestions are paginated inline

How did you test this?

manually

Publish to changelog?

no

Copy link
Copy Markdown
Contributor Author

adboio commented May 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@adboio adboio force-pushed the 05-20-feat_code_run_enricher_per_repo branch 3 times, most recently from 4dec6f5 to 0b04c91 Compare May 21, 2026 18:11
@adboio adboio marked this pull request as ready for review May 21, 2026 18:12
@adboio adboio requested a review from a team May 21, 2026 18:12
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/renderer/features/task-detail/components/SuggestedTasksPanel.tsx:57-59
`pageStart` is local state that persists across repo changes. When the user switches from repo A (was on page 2) to repo B that also has ≥`visibleCount` tasks, `effectivePageStart` stays at the previous offset and the user lands on an arbitrary page of the new repo's suggestions. A `useEffect` that resets `pageStart` to 0 whenever `selectedDirectory` changes would fix this.

```suggestion
  const [detailTask, setDetailTask] = useState<DiscoveredTask | null>(null);
  const [pageStart, setPageStart] = useState(0);
  const [pageDirection, setPageDirection] = useState<1 | -1>(1);

  // Reset pagination whenever the active repo changes so the user always
  // lands on page 1 of the new repo's suggestions.
  useEffect(() => {
    setPageStart(0);
  }, [selectedDirectory]);
```

### Issue 2 of 2
apps/code/src/renderer/features/setup/hooks/useSetupDiscovery.ts:19-27
**Effect fires twice on first-ever repo selection**

When a brand-new user selects their first repo, the effect runs with `discoveryEverStarted=false` and calls `startSetup(dir)`. Inside `startSetup`, `injectEnricherSuggestions` + `startDiscovery` are both kicked off. `startDiscovery` eventually calls `useSetupStore.getState().startDiscovery(dir, ...)` (after the async API task creation), which flips `discoveryByRepo[dir].status` to `"running"`. This makes `discoveryEverStarted` become `true`, re-running the effect with the same `selectedDirectory` and now calling `startEnricherForRepo(dir)` — even though `startSetup` already invoked `injectEnricherSuggestions`.

The in-process and store guards (`enricherSuggestionsRunningByRepo.has(dir)` / `enricherStatus === "done"|"running"`) prevent an actual double-run, so there is no visible breakage. But if the enricher finishes with an error in the narrow window between the two effect firings, it would be retried unexpectedly on the same selection. Consider removing `discoveryEverStarted` from the deps and capturing the branch decision in a `useRef` keyed to `selectedDirectory`.

Reviews (1): Last reviewed commit: "feat(code): remove suggested tasks from ..." | Re-trigger Greptile

Comment on lines +57 to +59
const [detailTask, setDetailTask] = useState<DiscoveredTask | null>(null);
const [pageStart, setPageStart] = useState(0);
const [pageDirection, setPageDirection] = useState<1 | -1>(1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 pageStart is local state that persists across repo changes. When the user switches from repo A (was on page 2) to repo B that also has ≥visibleCount tasks, effectivePageStart stays at the previous offset and the user lands on an arbitrary page of the new repo's suggestions. A useEffect that resets pageStart to 0 whenever selectedDirectory changes would fix this.

Suggested change
const [detailTask, setDetailTask] = useState<DiscoveredTask | null>(null);
const [pageStart, setPageStart] = useState(0);
const [pageDirection, setPageDirection] = useState<1 | -1>(1);
const [detailTask, setDetailTask] = useState<DiscoveredTask | null>(null);
const [pageStart, setPageStart] = useState(0);
const [pageDirection, setPageDirection] = useState<1 | -1>(1);
// Reset pagination whenever the active repo changes so the user always
// lands on page 1 of the new repo's suggestions.
useEffect(() => {
setPageStart(0);
}, [selectedDirectory]);
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/task-detail/components/SuggestedTasksPanel.tsx
Line: 57-59

Comment:
`pageStart` is local state that persists across repo changes. When the user switches from repo A (was on page 2) to repo B that also has ≥`visibleCount` tasks, `effectivePageStart` stays at the previous offset and the user lands on an arbitrary page of the new repo's suggestions. A `useEffect` that resets `pageStart` to 0 whenever `selectedDirectory` changes would fix this.

```suggestion
  const [detailTask, setDetailTask] = useState<DiscoveredTask | null>(null);
  const [pageStart, setPageStart] = useState(0);
  const [pageDirection, setPageDirection] = useState<1 | -1>(1);

  // Reset pagination whenever the active repo changes so the user always
  // lands on page 1 of the new repo's suggestions.
  useEffect(() => {
    setPageStart(0);
  }, [selectedDirectory]);
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 19 to +27
useEffect(() => {
if (startedRef.current) return;
// Only auto-fire from a clean "idle" state. "done" needs no rerun, and
// "error" (which now includes interrupted runs persisted across boots —
// see setupStore partialize) requires an explicit user retry to recover.
if (discoveryStatus !== "idle") return;
if (!selectedDirectory) return;

startedRef.current = true;
get<SetupRunService>(RENDERER_TOKENS.SetupRunService).startSetup(
selectedDirectory,
);
}, [discoveryStatus, selectedDirectory]);
const service = get<SetupRunService>(RENDERER_TOKENS.SetupRunService);
if (discoveryEverStarted) {
service.startEnricherForRepo(selectedDirectory);
} else {
service.startSetup(selectedDirectory);
}
}, [discoveryEverStarted, selectedDirectory]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Effect fires twice on first-ever repo selection

When a brand-new user selects their first repo, the effect runs with discoveryEverStarted=false and calls startSetup(dir). Inside startSetup, injectEnricherSuggestions + startDiscovery are both kicked off. startDiscovery eventually calls useSetupStore.getState().startDiscovery(dir, ...) (after the async API task creation), which flips discoveryByRepo[dir].status to "running". This makes discoveryEverStarted become true, re-running the effect with the same selectedDirectory and now calling startEnricherForRepo(dir) — even though startSetup already invoked injectEnricherSuggestions.

The in-process and store guards (enricherSuggestionsRunningByRepo.has(dir) / enricherStatus === "done"|"running") prevent an actual double-run, so there is no visible breakage. But if the enricher finishes with an error in the narrow window between the two effect firings, it would be retried unexpectedly on the same selection. Consider removing discoveryEverStarted from the deps and capturing the branch decision in a useRef keyed to selectedDirectory.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/setup/hooks/useSetupDiscovery.ts
Line: 19-27

Comment:
**Effect fires twice on first-ever repo selection**

When a brand-new user selects their first repo, the effect runs with `discoveryEverStarted=false` and calls `startSetup(dir)`. Inside `startSetup`, `injectEnricherSuggestions` + `startDiscovery` are both kicked off. `startDiscovery` eventually calls `useSetupStore.getState().startDiscovery(dir, ...)` (after the async API task creation), which flips `discoveryByRepo[dir].status` to `"running"`. This makes `discoveryEverStarted` become `true`, re-running the effect with the same `selectedDirectory` and now calling `startEnricherForRepo(dir)` — even though `startSetup` already invoked `injectEnricherSuggestions`.

The in-process and store guards (`enricherSuggestionsRunningByRepo.has(dir)` / `enricherStatus === "done"|"running"`) prevent an actual double-run, so there is no visible breakage. But if the enricher finishes with an error in the narrow window between the two effect firings, it would be retried unexpectedly on the same selection. Consider removing `discoveryEverStarted` from the deps and capturing the branch decision in a `useRef` keyed to `selectedDirectory`.

How can I resolve this? If you propose a fix, please make it concise.

@adboio adboio changed the title feat(code): run enricher per repo feat(code): suggested task cleanup May 22, 2026
@adboio adboio force-pushed the 05-20-feat_code_run_enricher_per_repo branch from 0b04c91 to 67260f4 Compare May 22, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant